package com.woniu.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author yellow Docter
 * @date 2022 -05-12
 * @desc
 */
@Data
@ApiModel(description = "返回结果的对象")
public class R {

    // 数据
    @ApiModelProperty("数据")
    private Object data;

    // 信息
    @ApiModelProperty("信息提示")
    private String msg;

    // 状态码
    @ApiModelProperty("状态码")
    private Integer code;

    public static R OK(){
        R result = new R();
        result.setMsg("操作成功");
        result.setCode(Constants.SUCCESS_CODE);
        return result;
    }

    public static R OK(String msg){
        R result = new R();
        result.setMsg(msg);
        result.setCode(Constants.SUCCESS_CODE);
        return result;
    }

    public static R ERROR() {
        R result = new R();
        result.setMsg("操作失败");
        result.setCode(Constants.ERROR_CODE);
        return result;
    }

    public static R ERROR(String msg) {
        R result = new R();
        result.setMsg(msg);
        result.setCode(Constants.ERROR_CODE);
        return result;
    }

}
